package com.chaoshi.common;

import lombok.Getter;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Configuration;
import org.springframework.validation.annotation.Validated;

import javax.validation.constraints.Max;
import javax.validation.constraints.Min;
import java.math.BigDecimal;

@Getter
@Configuration
@ConfigurationProperties(prefix = "prices")
@Validated
public class FruitPrices {
    @Min(0)
    private BigDecimal apple;

    @Min(0)
    private BigDecimal strawberry;

    @Min(0)
    private BigDecimal mango;


    public void setApple(double apple) { this.apple = BigDecimal.valueOf(apple); }
    public void setStrawberry(double strawberry) { this.strawberry = BigDecimal.valueOf(strawberry); }
    public void setMango(double mango) { this.mango = BigDecimal.valueOf(mango); }

    public BigDecimal getApple() {
        return apple;
    }

    public BigDecimal getStrawberry() {
        return strawberry;
    }

    public BigDecimal getMango() {
        return mango;
    }
}